package cn.stylefeng.guns.modular.business.custom.enums;

public enum FinanceTypeEnum {

    SPOT(1, "现付"),
    DELIVERY(2, "到付"),
    BACK_PAY(3, "欠付"),
    SLOT(4, "月结"),
    KICKBACK(5, "客户返款"),
    PICK(6, "提车费"),
    TAKE(7, "送车费"),
    TRANSPORT(8, "承运费"),
    OTHER(9, "其他费用"),
    CUSTOMER(10, "自定义");


    FinanceTypeEnum(int type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public int type;

    private String desc;

    /**
     * 用于switch
     * @param type
     * @return
     */
    public static FinanceTypeEnum getByType(int type) {
        for (FinanceTypeEnum ft : values()) {
            if (ft.type == type) {
                return ft;
            }
        }
        return null;
    }

    public static String getValue(Integer type) {
        if (type == null) {
            return "";
        }
        FinanceTypeEnum[] pts = FinanceTypeEnum.values();
        for (FinanceTypeEnum pt : pts) {
            if (type == pt.type) {
                return pt.desc;
            }
        }
        return "";
    }
}
